package com.fz.controller;

import com.fz.entity.Carousel;
import com.fz.mapper.AdminPageManageMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by Z-C-Y on 2018-03-08.
 * <p>
 * 后台页面管理
 */
@Controller
public class AdminPageManageController {
    @Autowired
    protected AdminPageManageMapper adminPageManageMapper;

    /*index.jsp首页管理 */
    @RequestMapping("/admin/hheadpage2")
    public String indexManage(Model model, HttpServletRequest request) {
        /*删除轮播图*/
        if (request.getParameter("headimage") != null && !"".equals(request.getParameter("headimage"))) {
            int deleteimage = Integer.parseInt(request.getParameter("headimage"));
             adminPageManageMapper.deleteImage(deleteimage);
        }
        /*添加首页轮播图*/

        /*首页轮播图*/
        List<Carousel> listCarousel = adminPageManageMapper.queryCarousel();
        model.addAttribute("listCarousel", listCarousel);
        return "admin/hheadpage2";/*redirect是重定向*/
    }




}
